var categoryOrdered = new Array();
function InitPercent()
{
    for(var key in categoryOrdered)
    {
        $('#reportcadid' + categoryOrdered[key].id).width(categoryOrdered[key].percent + '%');   
    }
    
}
function lessthan(a,b)
{
    if(a.money - b.money > 0)
    {
        //console.log(a.name + a.money + ">" + b.name + b.money );
        return -1;
    } else 
    {
        //console.log(a.name + a.money + "<" + b.name + b.money );
        return 1;
    }
}

function InitReport()
{
     datamodel.init();
     
    var maxMoney = 0;
    categoryOrdered = datamodel.categorys;
    categoryOrdered.sort(lessthan);
    for(var key in categoryOrdered)
    {
        if(categoryOrdered[key].type == 0)
        {
            if(categoryOrdered[key].money > maxMoney)
            {
                maxMoney = categoryOrdered[key].money;
            }
        }
        //console.log(categoryOrdered[key].name + categoryOrdered[key].money);
    }  
    $("#reportList").html("");
    for(var key in categoryOrdered)
    {
        if(categoryOrdered[key].type != 0)
        {
            continue;
        }
        var categoryReportHtml = "<li class=\"{0} li\"><a><i class=\"{0}-icon\"></i><div class=\"left\">" +
                             "<span class=\"accoutname\">{1}</span><br /> " + 
                             "<div class=\"bar\"><div id=\"reportcadid{3}\"class=\"process process-{0}\" style=\"width:0%\"></div></div>" + 
                             "</div> <div class=\"right\"> <span class=\"money\">￥{2}</span></div></a> </li>";
                             
                             
        categoryOrdered[key].percent = categoryOrdered[key].money / maxMoney * 100;
        
        categoryReportHtml = 
        categoryReportHtml.format(catidToClassStr(categoryOrdered[key].id),categoryOrdered[key].name,categoryOrdered[key].money,categoryOrdered[key].id)
        $("#reportList").append(categoryReportHtml);
        
     
        //$('#reportcadid' + category[key].id).width(percent + '%');   
        
        
    }
    
    
                             
                        
                            
                            
                                
                                
                            
                           
                               
                            
                        
                   
    
    
    
}